package com.example.demooptimizeif.controller;

import com.example.demooptimizeif.factory.AbstractUserService;
import com.example.demooptimizeif.factory.ServiceFactory;
import com.example.demooptimizeif.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version 1.0.0
 * @className: UserController
 * @description:
 * @author: zhangjunfa
 * @date: 2023/9/2 12:22
 */
@RestController
@RequestMapping
public class UserController {
    private final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @GetMapping("/getUser")
    public Object getUser(@RequestParam(name = "type") Integer type) {
        return userService.getUser(type);
    }

    @GetMapping("/getUsers")
    public Object getUsers(@RequestParam(name = "type") Integer type) {
        userService.getUsers(type);
        return type;
    }

    @GetMapping("/getUserFactory")
    public Object getUserFactory(@RequestParam(name = "type") Integer type) {
        ServiceFactory.getUserService(type);
        return type;
    }
}
